package com.lyc.controller;

import com.lyc.pojo.Users;
import com.lyc.tool.SYS;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.bind.support.SessionStatus;

import javax.servlet.http.HttpSession;
import java.sql.SQLOutput;

@Controller
@RequestMapping("/admin")
public class AdminController {

    @RequestMapping("/admin/{admin}")
    public String show(@PathVariable("admin") String admin, HttpSession session){
        Object attribute = session.getAttribute(SYS.SYS_USER);
      // System.out.println(attribute+"\t"+(attribute instanceof Users));
        return  admin;
    }

    @RequestMapping("/remove")
    public String remove(SessionStatus status, HttpSession session){
        session.removeAttribute(SYS.SYS_USER);
        status.setComplete();
        //session.invalidate();
        return "adminLogin";
    }

}
